package com.list.model.abstracts;

import java.util.HashMap;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Property;
import com.list.data.structure.TripleWeightsList;
import com.list.model.specific.FileInitializer;
import com.list.model.specific.MemoryInitializer;

public abstract class BaseModel {
	private Model model;
//	private Model instanceModel;
	private int iniType;
	private Initializable inin;
	private HashMap<Property, TripleWeightsList> tripleWeightList;
	private HashMap<Property, Double> propertyWeightTable;
//	private HashMap
	
	public HashMap<Property, Double> getPropertyWeightTable() {
		if(propertyWeightTable == null) {
			propertyWeightTable = new HashMap<Property, Double>();
		}
		return propertyWeightTable;
	}

	public void setPropertyWeightTable(HashMap<Property, Double> propertyWeightTable) {
		this.propertyWeightTable = propertyWeightTable;
	}

	public BaseModel(Model model) {
		this.model = model;
	}
	
	public Model getModel() {
		return model;
	}

	public void setModel(Model model) {
		if(model!=null) this.model = model;
	}

	public HashMap<Property, TripleWeightsList> getTripleWeightList() {
		if(this.tripleWeightList == null) this.tripleWeightList = new HashMap<Property, TripleWeightsList>();
		return tripleWeightList;
	}

	public void setTripleWeightList(
			HashMap<Property, TripleWeightsList> tripleWeightList) {
		this.tripleWeightList = tripleWeightList;
	}

	public abstract void loadOntology();
	public abstract Model getInstaceModel();
	public final void initialize(int ininType) {
		this.iniType = ininType;
		switch (ininType) {
		case 0:
			this.inin = new MemoryInitializer(this);
			break;
		case 1:
			this.inin = new FileInitializer();
			break;
		default:
			break;
		}
		this.inin.calculate();
	}
}
